package org.jivesoftware.smack.filter;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.packet.Packet;

public class AndFilter
  implements PacketFilter
{
  private List<PacketFilter> filters = new ArrayList();

  public AndFilter(PacketFilter[] paramArrayOfPacketFilter)
  {
    if (paramArrayOfPacketFilter == null)
      throw new IllegalArgumentException("Parameter cannot be null.");
    int i = paramArrayOfPacketFilter.length;
    int j = 0;
    while (true)
    {
      if (j >= i)
        return;
      PacketFilter localPacketFilter = paramArrayOfPacketFilter[j];
      if (localPacketFilter == null)
        throw new IllegalArgumentException("Parameter cannot be null.");
      this.filters.add(localPacketFilter);
      ++j;
    }
  }

  public boolean accept(Packet paramPacket)
  {
    int i;
    Iterator localIterator = this.filters.iterator();
    if (!(localIterator.hasNext()))
      i = 1;
    while (true)
    {
      do
        return i;
      while (((PacketFilter)localIterator.next()).accept(paramPacket));
      i = 0;
    }
  }

  public void addFilter(PacketFilter paramPacketFilter)
  {
    if (paramPacketFilter == null)
      throw new IllegalArgumentException("Parameter cannot be null.");
    this.filters.add(paramPacketFilter);
  }

  public String toString()
  {
    return this.filters.toString();
  }
}